package com.har.modules.business.controller;

import com.har.common.utils.PageUtils;
import com.har.common.utils.R;
import com.har.modules.business.entity.TBaseProductEntity;
import com.har.modules.business.service.TBaseProductService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 产品管理基础配置表
 *
 * @author macwy
 * @email 
 * @date 2018-06-26 16:38:42
 */
@RestController
@RequestMapping("business/tbaseproduct")
public class TBaseProductController {
    @Autowired
    private TBaseProductService tBaseProductService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("business:tbaseproduct:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tBaseProductService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("business:tbaseproduct:info")
    public R info(@PathVariable("id") Long id){
        TBaseProductEntity tBaseProduct = tBaseProductService.selectById(id);

        return R.ok().put("tBaseProduct", tBaseProduct);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("business:tbaseproduct:save")
    public R save(@RequestBody TBaseProductEntity tBaseProduct){
        tBaseProductService.insert(tBaseProduct);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("business:tbaseproduct:update")
    public R update(@RequestBody TBaseProductEntity tBaseProduct){
//        ValidatorUtils.validateEntity(tBaseProduct);
        tBaseProductService.updateAllColumnById(tBaseProduct);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("business:tbaseproduct:delete")
    public R delete(@RequestBody Long[] ids){
        tBaseProductService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
